////////////////////////////////////////////////////////////////////////////////
// options.h
// Servo interface board
// 
// This file includes all of the user-configuration for this firmware
// 


////////////////////////////////////////////////////////////////////////////////
// Configure Input and Output Channels
//
// NUM_INPUTS: Set to 8 for interface card
#define NUM_INPUTS	8

// Measurement channel numbers for each servo channel.
//#define CH1_INPUT_CHANNEL				CHANNEL_6  TEMPORARY FIX FOR BROKEN CHANNEL MJC
#define CH1_INPUT_CHANNEL				CHANNEL_UNUSED

#define CH2_INPUT_CHANNEL				CHANNEL_4
#define CH3_INPUT_CHANNEL				CHANNEL_5
#define CH4_INPUT_CHANNEL				CHANNEL_6
#define CH5_INPUT_CHANNEL				CHANNEL_7
#define CH6_INPUT_CHANNEL				CHANNEL_8
#define CH7_INPUT_CHANNEL				CHANNEL_2
#define CH8_INPUT_CHANNEL				CHANNEL_1
#define SPARE_INPUT_CHANNEL				CHANNEL_3

// NUM_OUTPUTS: Set to 8 for interface card
#define NUM_OUTPUTS	8

// Channel numbers for each output
// Use to re-arrange the channels on the input/output connector
//   - Only assign each channel to one output purpose
//   - If you don't want to use an output channel, set it to CHANNEL_UNUSED
//   - If you're set up to use Rudder Navigation (like MatrixNav), then you may want to swap
//     the aileron and runner channels so that rudder is CHANNEL_1, and aileron is 5.
// 
// NOTE: If your board is powered from your ESC through the throttle cable, make sure to
// connect THROTTLE_OUTPUT_CHANNEL to one of the built-in Outputs (1, 2, or 3) to make
// sure your board gets power.
// 
#define CH1_OUTPUT_CHANNEL			CHANNEL_8
#define CH2_OUTPUT_CHANNEL			CHANNEL_7
#define CH3_OUTPUT_CHANNEL			CHANNEL_6
#define CH4_OUTPUT_CHANNEL			CHANNEL_5
#define CH5_OUTPUT_CHANNEL			CHANNEL_4
#define CH6_OUTPUT_CHANNEL			CHANNEL_3
#define CH7_OUTPUT_CHANNEL			CHANNEL_2
#define CH8_OUTPUT_CHANNEL			CHANNEL_1

////////////////////////////////////////////////////////////////////////////////
// Throttle channel always defaults to minimum
// It is also limited to minimum at output
// The interface will report lower measurements to the CAN interface
// This is to provide failsafe action without upsetting the 
#define THROTTLE_INPUT_CHANNEL		CHANNEL_3
#define THROTTLE_OUTPUT_CHANNEL		CHANNEL_3
#define THROTTLE_MINIMUM_OUTPUT		2400	// Equivalent to 1.1ms

////////////////////////////////////////////////////////////////////////////////
// Mode Switch is ideally controlled by a 3-position switch on your transmitter.
// Often the Flap channel will be controlled by a 3-position switch.
// These are the thresholds for the cutoffs between low and middle, and between middle and high.
// Normal signals should fall within about 2000 - 4000.
#define MODE_INPUT_CHANNEL					CHANNEL_8
#define MODE_SWITCH_THRESHOLD_LOW			2600
#define MODE_SWITCH_THRESHOLD_HIGH			3400



////////////////////////////////////////////////////////////////////////////////
// The Failsafe Channel is the RX channel that is monitored for loss of signal
// Make sure this is set to a channel you actually have plugged into the UAV Dev Board!
// 
// No matter which input you use as your failsafe, make sure you are also sending
// valid servo pulses to Input channel 4 every ~20ms, or the failsafe will not work properly.
// Just making sure you have Input 4 connected to your receiver will accomplish this.
// 
// For a receiver that remembers a failsafe value for when it loses the transmitter signal,
// like the Spektrum AR6100, you can program the receiver's failsafe value to a value below
// the normal low value for that channel.  Then set the FAILSAFE_INPUT_MIN value to a value
// between the receiver's programmed failsafe value and the transmitter's normal lowest
// value for that channel.  This way the firmware can detect the difference between a normal
// signal, and a lost transmitter.
//
// FAILSAFE_INPUT_MIN and _MAX define the range within which we consider the radio on.
// Normal signals should fall within about 2000 - 4000.
#define FAILSAFE_INPUT_CHANNEL				THROTTLE_INPUT_CHANNEL
#define FAILSAFE_INPUT_MIN					2000
#define FAILSAFE_INPUT_MAX					4500


////////////////////////////////////////////////////////////////////////////////
// Servo Limits
// What is the limit of measured servo range which is correct
#define SERVO_ABS_MIN 1500
#define SERVO_ABS_MAX 4500

// What is the limit of servo output range which is correct
#define SERVO_OUT_MIN 1500
#define SERVO_OUT_MAX 4500 

////////////////////////////////////////////////////////////////////////////////
// Receive frame timout
// This is the longest allowable time between received pulses before
//  the frame is reset.  One count is 64us.
// The timeout is used to update the communications and reset the
//  receieve channels mask.
//  62 ~4ms
#define RX_FRAME_TIMEOUT  62

// The maximum number of PWM cycles without successful autopilot conenction
//  before reverting to manaal control
#define RX_MAX_TIMEOUTS  4

